package conf;

import java.io.File;
import java.io.IOException;
import java.util.Properties;
import file.FileUtil;

public class Configure {
	private static final String CONFIGURE_FILE_NAME = "conf.properties";

	private static final Properties config;

	private Configure() {
		// This constructor will never be invoked
	}

	static {
		config = new Properties();
		try {
			config.load(FileUtil.createInputStream(CONFIGURE_FILE_NAME));
		} catch (IOException e) {
			System.out.print("Cannot find the property file: " + CONFIGURE_FILE_NAME);
		}
	}

	public static String getProperty(String key) {
		return config.getProperty(key);
	}

	public static final String HOME_DIR = "homedir";
	public static final String LOGDIR = "logdir";
	public static final String LOG_FILE_SIZE = "logFileSize";
	public static final String LOG_FILE_LEVEL = "logFileLevel";
	public static final String LOG_STDOUT_LEVEL = "logStdoutLevel";

	public static String getHomeDir() {
		return getProperty(HOME_DIR);
	}

	public static String getLogDir() {
		return getHomeDir() + "//" + getProperty(LOGDIR);
	}

	public static File getLogDirFile() {
		return new File(getLogDir());
	}

}
